#!/bin/bash
echo -e "Para instalar poder el Stunnel Multi Certificado"
echo -e "Necesita tener instalado el Stunnel Normal"
echo -e "Continuar?"
while [[ ${yesno} != @(s|S|y|Y|n|N) ]]; do
read -p "[S/N]: " yesno
tput cuu1 && tput dl1
done
if [[ ${yesno} = @(s|S|y|Y) ]]; then
echo -e "Escriba un nombre para su nuevo certificado SSL"
echo -e "Ejemplo: SSLMexico"
read -p ": " certssl
echo -e "Escriba el puerto del Servicio a SSH o Dropbear"
echo -e "Ejemplo: 22"
read -p ": " portserv
echo -e "Escriba el Nuevo Puerto SSL a usar"
read -p ": " portssl
if lsof -Pi :$portssl -sTCP:LISTEN -t >/dev/null ; then
echo "Ya esta en uso ese puerto"
vpspack 10
else
openssl genrsa 2048 > $certssl.key
openssl req -new -key $certssl.key -x509 -days 1000 -out $certssl.crt
cat $certssl.crt $certssl.key > $certssl.pem
mv $certssl.pem /etc/stunnel/
echo "[$certssl] " >> /etc/stunnel/stunnel.conf
echo "cert = /etc/stunnel/$certssl.pem " >> /etc/stunnel/stunnel.conf
echo "accept = $portssl " >> /etc/stunnel/stunnel.conf
echo "connect = 127.0.0.1:$portserv" >> /etc/stunnel/stunnel.conf
sleep 5
echo "Reiniciando Servicio : Stunnel4"
service stunnel4 restart 1> /dev/null 2> /dev/null
sleep 5
fi
fi
echo -e "\033[1;31mPRESIONE ENTER PARA CONTINUAR\033[0m"
read -p " "
vpspack